package ch5;

import java.util.Scanner;

public class InputScore2 {

	public static void main(String[] args) {
		// 5人求平均
		Scanner in = new Scanner(System.in);
		int sum = 0, avg, s;
		int i = 1;
		for (; i <= 5; i++) {
			System.out.println("请输入第" + i + "位同学的成绩：");
			s = in.nextInt();
			if (s < 0) {
				System.out.println("输入错误");
				break;
			}
			sum += s;
		}
		if (i > 5) {
			avg = sum / 5;
			System.out.println("平均分为:" + avg);
		}
	}

}
